/* eslint-disable */
'use strict'

const logger = require('log4js').getLogger("database")
const dbPool = require('./dbConfig.js')(process.env.NODE_ENV)

module.exports = {
  execute: (sql, values, callback) => {
    if (!sql) {
      return
    }
    dbPool.getConnection((err, connection) => {
      connection.query(sql, values, (err, res, fields) => {
        if (err) {
          connection.rollback(() => {
            logger.error(err)
          })
        }
        connection.release()
        callback && callback(err, res, fields)
      })
    })
  }
}